<?php
/**
 * QQAS - share your knowledge to the world!
 *
 * @author		xiaochong0302 <xiaochong0302@gmail.com>
 * @copyright	Copyright (c) 2011, Koogua Studio.
 * @license		http://www.qqas.org/user_guide/license.html
 * @link		http://www.qqas.org
 * @since		Version 1.0
 * @filesource
 */


class ActivityModel extends Model
{


	//本周所获积分
	public function userWeekPoints($userID)
	{
		$begin = date('w');
		$end = 6 - $begin;
		$starttime = strtotime("-{$begin} day");
		$endtime = strtotime("+{$end} day");
		$map = array(
			'user_id' => $userID,
			'create_time' => array('between', array($starttime, $endtime)),
		);
		$weekPoints = $this->where($map)->sum('point');
		return intval($weekPoints);
	}


	//用户动态
	public function userActivities($userID, $limit=10)
	{
		$map = array(
			'user_id' => $userID,
		);
		$order = array('activity_id' => 'desc');
		return $this->where($map)->order($order)->limit($limit)->select();
	}

}


/* End of file ActivityModel.class.php */
/* Location: ./App/Lib/Model/ActivityModel.class.php */